package com.survey.demo.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.survey.demo.R;
import com.survey.demo.app.AppAdapter;
import com.survey.demo.http.bean.HomeEntity;

/**
 *    author : Android 轮子哥
 *    github : https://github.com/getActivity/AndroidProject
 *    time   : 2019/09/22
 *    desc   : 状态数据列表
 */
public final class HomeShopAdapter extends AppAdapter<HomeEntity> {

    public HomeShopAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {

        private final TextView titleName;
        private final TextView priceName;
        private final TextView zyName;

        private ViewHolder() {
            super(R.layout.home_shop_item);
            titleName = findViewById(R.id.title_name);
            priceName = findViewById(R.id.price_tv);
            zyName = findViewById(R.id.zy_tv);
        }

        @Override
        public void onBindView(int position) {
            titleName.setText(getItem(position).getTitle());
            priceName.setText("¥"+getItem(position).getPrice());
            if(getItem(position).isUse()){
                zyName.setVisibility(View.VISIBLE);
            }else {
                zyName.setVisibility(View.GONE);
            }
        }
    }
}